<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title></title>
        <%@include file ="../include/link.jsp"%>
        <script language="javascript" type="text/javascript">
            //显示角色详细信息
            function showDetail(flag, a) {
                var detailDiv = a.parentNode.find("div")[0];
                if (flag) {
                    detailDiv.style.display = "block";
                }
                else
                    detailDiv.style.display = "none";
            }
            //重置密码
            function resetPwd() {
                alert("请至少选择一条数据！");
                //document.getElementById("operate_result_info").style.display = "block";
            }
          //修改
            function modifyAdmin(id) {
                /* $("#hi").value=id;
 				$("#hi").name="modify";
 				$("#myform").submit(); */
 				$("#hi").val(id);
                $("#hi").attr("name","modify");
 				var path = "${pageContext.request.contextPath}/admin/DeleteAdminServlet";  
 			    $('#myform').attr("action", path).submit();; 
             }
            //删除
            function deleteAdmin(id) {
              /*  var r = window.confirm("确定要删除此管理员吗？");
                $("operate_result_info").style.display = "block"; */
                $("#hi").val(id);
                $("#hi").attr("name","delete");
				//$("#hi").name="delete";
				/* $("#myform").submit(); */
				$.ajax({
        			url:'${pageContext.request.contextPath}/admin/DeleteAdminServlet',
        			type:"post",
        			data:$("#myform").serialize(),
        			success:function(result){
        				alert("删除成功");
        				$("#"+id).remove();
        				if(result==true){
	        				setTimeout(function(){
	        					$("#save_result_info").show();
	        				},3000)		        				
        				}
        			}
        		})
            }
            //全选
            function selectAdmins(inputObj) {
                var inputArray = $("#datalist").find("input");
                for (var i = 1; i < inputArray.length; i++) {
                    if (inputArray[i].type == "checkbox") {
                        inputArray[i].checked = inputObj.checked;
                    }
                }
            }
        </script>       
    </head>
    <body>
        <!--Logo区域开始-->
        <div id="header">
            <img src="../images/logo.png" alt="logo" class="left"/>
            <a href="#">[退出]</a>            
        </div>
        <!--Logo区域结束-->
        <!--导航区域开始-->
        <div id="navi">                        
            <ul id="menu">
                <%@include file ="../include/main.jsp"%>
            </ul>            
        </div>
        <!--导航区域结束-->
        <!--主要区域开始-->
        <div id="main">
            <form id="myform" action="" method="post">
                <!--查询-->
                <div class="search_add">
                    <div>
                        模块：	
                        <select id="selModules" class="select_search">
                            <option>全部</option>
                            <option>管理员管理</option>
                            <option>资费管理</option>
                            <option>账务账号</option>
                            <option>业务账号</option>
                            <option>账单管理</option>
                            <option>报表</option>
                        </select>
                    </div>
<!--                     <div>角色：<input type="text" value="" class="text_search width200" /></div> -->
                    <div><input type="button" value="搜索" class="btn_search"/></div>
                    <input type="button" value="密码重置" class="btn_add" onclick="resetPwd();" />
                    <input type="button" value="增加" class="btn_add" onclick="location.href='../view/admin/admin_add.jsp';" />
                </div>
                <!--删除和密码重置的操作提示-->
                <div id="operate_result_info" class="operate_fail">
                    <img src="../images/close.png" onclick="this.parentNode.style.display='none';" />
                    <span>删除失败！数据并发错误。</span><!--密码重置失败！数据并发错误。-->
                </div> 
                <!--数据区域：用表格展示数据-->     
                <div id="data">            
                    <table id="datalist">
                        <tr>
                            <th class="th_select_all">
                                <input type="checkbox" onclick="selectAdmins(this);" />
                                <span>全选</span>
                            </th>
                            <th>管理员ID</th>
                            <th>姓名</th>
                            <th>登录名</th>
                            <th>电话</th>
                            <th>电子邮件</th>
                            <th>授权日期</th>
                            <th class="width100">拥有权限</th>
                            <th></th>
                        </tr>
                         <c:forEach items="${sessionScope.la}" var="adm">                      
	                        <tr>
	                            <td><input type="checkbox" /></td>
	                            <td>${adm.adm_no}</td>
	                            <td>${adm.adm_name}</td>
	                            <td>${adm.adm_user}</td>
	                            <td>${adm.adm_tel }</td>
	                            <td>${adm.adm_email}</td>
	                            <td>${adm.adm_date}</td>
	                            
	                            <td>
	                                <a class="summary"  onmouseover="showDetail(true,this);" onmouseout="showDetail(false,this);">${fn:substringBefore(adm.fpermiss,",")}</a>
	                                <!--浮动的详细信息-->
	                                <div class="detail_info">
	                            	${adm.permisss}
	                                </div>
	                            </td>
	                            <td class="td_modi">
	                                <input type="button" value="修改" class="btn_modify" onclick="modifyAdmin(${adm.adm_no})" />
	                                <input type="button" value="删除" class="btn_delete" onclick="deleteAdmin(${adm.adm_no})" />

	                            </td>                                                      
	                        </tr>
                        </c:forEach>
                        <input type="hidden" id="hi" name="" value=""/>
                    </table>
                </div>
                <!--分页-->
                <div id="pages">
        	        <a href="#">上一页</a>
                    <a href="#" class="current_page">1</a>
                    <a href="#">2</a>
                    <a href="#">3</a>
                    <a href="#">4</a>
                    <a href="#">5</a>
                    <a href="#">下一页</a>
                </div>                    
            </form>
        </div>
        <!--主要区域结束-->
        <div id="footer">       
        </div>
    </body>
</html>
